Attribute AutoVerbMenu.VB_Description = "Returns/sets a value that indicating whether the selected object's verbs will be displayed in a popup menu when the right mouse button is clicked."
AutoVerbMenu = txt.AutoVerbMenu
End Property
Property Let AutoVerbMenu(ByVal fAutoVerbMenuA As Boolean)
txt.AutoVerbMenu = fAutoVerbMenuA
PropertyChanged "AutoVerbMenu"
End Property
Property Get BackColor() As OLE_COLOR
Attribute BackColor.VB_Description = "Returns/sets the background color of an object."
BackColor = txt.BackColor
End Property
Property Let BackColor(ByVal clrBackColor As OLE_COLOR)
txt.BackColor = clrBackColor
PropertyChanged "BackColor"
End Property
Property Get BorderStyle() As RichTextLib.BorderStyleConstants
Attribute BorderStyle.VB_Description = "Returns/sets the border style for an object."
BorderStyle = txt.BorderStyle
End Property
Property Let BorderStyle(ByVal ordBorderStyle As RichTextLib.BorderStyleConstants)
txt.BorderStyle = ordBorderStyle
PropertyChanged "BorderStyle"
End Property
Property Get BulletIndent() As Single
Attribute BulletIndent.VB_Description = "Returns or sets the amount of indent used when SelBullet is set to True."
BulletIndent = txt.BulletIndent
End Property
Property Let BulletIndent(ByVal rBulletIndentA As Single)
Property Let DirtyBit(ByVal fDirtyBitA As Boolean)
Call SendMessage(txt.hWnd, EM_SETMODIFY, _
ByVal -CLng(fDirtyBitA), ByVal 0&)
StatusEvent
End Property
#If 0 Then
Property Get DragIcon() As Picture
Set DragIcon = txt.DragIcon
End Property
Property Let DragIcon(picDragIconA As Picture)
Set txt.DragIcon = picDragIconA
PropertyChanged "DragIcon"
End Property
Property Get DragMode() As DragModeConstants
DragMode = txt.DragMode
End Property
Property Let DragMode(ByVal ordDragModeA As DragModeConstants)
txt.DragMode = ordDragModeA
PropertyChanged "DragMode"
End Property
#End If
' Read-only, run-time only
Property Get FilePath() As String
FileName = sFilePath
End Property
' Run time or design time
Property Get FileName() As String
If sFilePath <> sEmpty Then FileName = GetFileBaseExt(sFilePath)
End Property
' Design-time only (use LoadFile at run time)
Property Let FileName(sFileNameA As String)
If Ambient.UserMode Then ErrRaise eeSetNotSupportedAtRuntime
' Can't pass through design-time errors
On Error GoTo FailFileName
If sFileNameA = sEmpty Then
' Empty text only if it comes from a file
If sFilePath <> sEmpty Then Text = sEmpty
sFilePath = sEmpty
Else
sFileNameA = GetFullPath(sFileNameA)
LoadFile sFileNameA
sFilePath = sFileNameA
End If
PropertyChanged "FileName"
Exit Property
FailFileName:
' Could empty FileName and Text, but I choose to ignore them
End Property
Property Get Font() As Font
Attribute Font.VB_Description = "Returns a Font object."
Attribute Font.VB_UserMemId = -512
Set Font = txt.Font
End Property
Property Set Font(ByVal fntA As Font)
Dim fDirty As Boolean
fDirty = DirtyBit
Set txt.Font = fntA
' Changing the font shouldn't dirty the file in TextMode
If TextMode Then DirtyBit = fDirty
PropertyChanged "Font"
End Property
Property Get TextColor() As OLE_COLOR
Attribute TextColor.VB_Description = "Returns/sets the foreground color used to display text."
Attribute TextColor.VB_MemberFlags = "400"
TextColor = txt.SelColor
End Property
Property Let TextColor(ByVal clrTextColorA As OLE_COLOR)
With txt
If TextMode Then
Dim fEnabled As Boolean, fDirty As Boolean
Dim iStart As Long, iLength As Long
fDirty = DirtyBit
' Save selection
SelVisible False
iStart = .SelStart
iLength = .SelLength
' Select all and change color
.SelStart = 0
.SelLength = Characters
.SelColor = clrTextColorA
' Restore selection
.SelStart = iStart
.SelLength = iLength
SelVisible True
' Changing the color shouldn't dirty the text in text mode
DirtyBit = fDirty
End If
PropertyChanged "TextColor"
End With
End Property
Property Get HideSelection() As Boolean
Attribute HideSelection.VB_Description = "Returns/sets a value that specifies if the selected item remains highlighted when a control loses focus."
HideSelection = txt.HideSelection
End Property
Property Let HideSelection(ByVal fHideSelectionA As Boolean)
txt.HideSelection = fHideSelectionA
End Property
' Read only
Property Get hWnd() As Long
Attribute hWnd.VB_Description = "Returns a handle to a control."
Attribute hWnd.VB_MemberFlags = "400"
hWnd = txt.hWnd
End Property
Property Get Locked() As Boolean
Attribute Locked.VB_Description = "Returns/sets a value indicating whether the contents can be edited."
Locked = txt.Locked
End Property
Property Let Locked(ByVal fLockedA As Boolean)
txt.Locked = fLockedA
PropertyChanged "Locked"
End Property
Property Get MousePointer() As MousePointerConstants
Attribute MousePointer.VB_Description = "Returns/sets a value indicating the type of mouse pointer displayed when the mouse is over the control at run time."
MousePointer = txt.MousePointer
End Property
Property Let MousePointer(ByVal ordMousePointerA As MousePointerConstants)
txt.MousePointer = ordMousePointerA
PropertyChanged "MousePointer"
End Property
Property Get MouseIcon() As Picture
Attribute MouseIcon.VB_Description = "Sets a custom mouse icon."
Set MouseIcon = txt.MouseIcon
End Property
Property Set MouseIcon(ByVal picMouseIcon As Picture)
Set txt.MouseIcon = picMouseIcon
PropertyChanged "MouseIcon"
End Property
Property Get OLEDragMode() As OLEDragConstants
Attribute OLEDragMode.VB_Description = "Returns/Sets whether this control can act as an OLE drag/drop source, and whether this process is started automatically or under programmatic control."
OLEDragMode = txt.OLEDragMode
End Property
Property Let OLEDragMode(ByVal ordOLEDragMode As OLEDragConstants)
txt.OLEDragMode() = ordOLEDragMode
PropertyChanged "OLEDragMode"
End Property
Property Get OLEDropMode() As OLEDropConstants
Attribute OLEDropMode.VB_Description = "Returns/Sets whether this control can act as an OLE drop target."
OLEDropMode = txt.OLEDropMode
End Property
Property Let OLEDropMode(ByVal ordOLEDropMode As OLEDropConstants)
txt.OLEDropMode() = ordOLEDropMode
PropertyChanged "OLEDropMode"
End Property
Property Get OLEObjects() As IOLEObjects
Attribute OLEObjects.VB_Description = "The insertable objects in an RTF file."
Set OLEObjects = txt.OLEObjects
End Property
Property Get OverWrite() As Boolean
OverWrite = fOverWrite
End Property
Property Let OverWrite(ByVal fOverWriteA As Boolean)
Attribute RightMargin.VB_Description = "Sets the right margin used for textwrap, centering, etc."
RightMargin = txt.RightMargin
End Property
Property Let RightMargin(ByVal rRightMargin As Single)
If rRightMargin < 0 Or rRightMargin > 65535 Then
rRightMargin = 65535
End If
txt.RightMargin = rRightMargin
PropertyChanged "RightMargin"
End Property
Property Get SelAlignment() As Variant
Attribute SelAlignment.VB_Description = "Returns/sets a value that controls the alignment of the paragraphs."
Attribute SelAlignment.VB_MemberFlags = "400"
If TextMode Then
SelAlignment = Null
Else
SelAlignment = txt.SelAlignment
End If
End Property
Property Let SelAlignment(ByVal vSelAlignmentA As Variant)
If TextMode Then Exit Property
txt.SelAlignment = vSelAlignmentA
End Property
Property Get SelBold() As Variant
Attribute SelBold.VB_Description = "Returns/set the bold format of the currently selected text."
Attribute SelBold.VB_MemberFlags = "400"
If TextMode Then
SelBold = Null
Else
SelBold = txt.SelBold
End If
End Property
Property Let SelBold(ByVal vSelBold As Variant)
If TextMode Then Exit Property
txt.SelBold = vSelBold
End Property
Property Get SelBullet() As Variant
Attribute SelBullet.VB_Description = "Returns/sets a value that determines if a paragraph in the control containing the current selection or insertion point has the bullet style."
Attribute SelBullet.VB_MemberFlags = "400"
If TextMode Then
SelBullet = Null
Else
SelBullet = txt.SelBullet
End If
End Property
Property Let SelBullet(ByVal vSelBullet As Variant)
If TextMode Then Exit Property
txt.SelBullet = vSelBullet
End Property
Property Get SelCharOffset() As Variant
Attribute SelCharOffset.VB_Description = "Returns/sets a value that determines whether text in the control appears on the baseline (normal), as a superscript above the baseline, or as a subscript below the baseline."
Attribute SelCharOffset.VB_MemberFlags = "400"
If TextMode Then
SelCharOffset = Null
Else
SelCharOffset = txt.SelCharOffset
End If
End Property
Property Let SelCharOffset(ByVal vSelCharOffset As Variant)
If TextMode Then Exit Property
txt.SelCharOffset = vSelCharOffset
End Property
Property Get SelColor() As Variant
Attribute SelColor.VB_Description = "Returns/sets a value that determines the color of text in the control."
Attribute SelColor.VB_MemberFlags = "400"
If TextMode Then
SelColor = Null
Else
SelColor = txt.SelColor
End If
End Property
Property Let SelColor(ByVal vSelColor As Variant)
If TextMode Then Exit Property
txt.SelColor = vSelColor
End Property
Property Get SelFontName() As Variant
Attribute SelFontName.VB_Description = "Returns/sets the font used to display the currently selected text or the character(s) immediately following the insertion point in the control."
Attribute SelFontName.VB_MemberFlags = "400"
If TextMode Then
SelFontName = Null
Else
SelFontName = txt.SelFontName
End If
End Property
Property Let SelFontName(ByVal vSelFontName As Variant)
If TextMode Then Exit Property
txt.SelFontName = vSelFontName
End Property
Property Get SelFontSize() As Variant
Attribute SelFontSize.VB_Description = "Returns/sets a value that specifies the size of the font used to display text."
Attribute SelFontSize.VB_MemberFlags = "400"
If TextMode Then
SelFontSize = Null
Else
SelFontSize = txt.SelFontSize
End If
End Property
Property Let SelFontSize(ByVal vSelFontSize As Variant)
If TextMode Then Exit Property
txt.SelFontSize = vSelFontSize
End Property
Property Get SelHangingIndent() As Variant
Attribute SelHangingIndent.VB_Description = "Returns/sets the distance between left edge of the first line of text in the selected paragraph(s) (as specified by SelIndent) and the left edge of subsequent lines of text in the same paragraphs."
Attribute SelHangingIndent.VB_MemberFlags = "400"
If TextMode Then
SelHangingIndent = Null
Else
SelHangingIndent = txt.SelHangingIndent
End If
End Property
Property Let SelHangingIndent(ByVal vSelHangingIndent As Variant)
If TextMode Then Exit Property
txt.SelHangingIndent = vSelHangingIndent
End Property
Property Get SelIndent() As Variant
Attribute SelIndent.VB_Description = "Returns/sets the distance between the left edge of the control and the left edge of the text that is selected or added at the current insertion point."
Attribute SelIndent.VB_MemberFlags = "400"
If TextMode Then
SelIndent = Null
Else
SelIndent = txt.SelIndent
End If
End Property
Property Let SelIndent(ByVal vSelIndent As Variant)
If TextMode Then Exit Property
txt.SelIndent = vSelIndent
End Property
Property Get SelItalic() As Variant
Attribute SelItalic.VB_Description = "Returns/set the italic format of the currently selected text."
Attribute SelItalic.VB_MemberFlags = "400"
If TextMode Then
SelItalic = Null
Else
SelItalic = txt.SelItalic
End If
End Property
Property Let SelItalic(ByVal vSelItalic As Variant)
If TextMode Then Exit Property
txt.SelItalic = vSelItalic
End Property
Property Get SelLength() As Long
Attribute SelLength.VB_Description = "Returns/sets the number of characters selected."
Attribute SelLength.VB_MemberFlags = "400"
SelLength = txt.SelLength
End Property
Property Let SelLength(ByVal iSelLengthA As Long)
txt.SelLength = iSelLengthA
End Property
Property Get SelProtected() As Variant
Attribute SelProtected.VB_Description = "Returns/sets a value that determines if the selected text is protected against editing."
Attribute SelProtected.VB_MemberFlags = "400"
If TextMode Then
SelProtected = Null
Else
SelProtected = txt.SelProtected
End If
End Property
Property Let SelProtected(ByVal vSelProtected As Variant)
If TextMode Then Exit Property
txt.SelProtected = vSelProtected
End Property
Property Get SelRightIndent() As Variant
Attribute SelRightIndent.VB_Description = "Returns/sets the distance between the right edge of the control and the right edge of the text that is selected or added at the current insertion point."
Attribute SelRightIndent.VB_MemberFlags = "400"
If TextMode Then
SelRightIndent = Null
Else
SelRightIndent = txt.SelRightIndent
End If
End Property
Property Let SelRightIndent(ByVal vSelRightIndent As Variant)
If TextMode Then Exit Property
txt.SelRightIndent = vSelRightIndent
End Property
Property Get SelRTF() As String
Attribute SelRTF.VB_Description = "Returns/sets the text (in .RTF format) in the current selection of a control."
Attribute SelRTF.VB_MemberFlags = "400"
If TextMode Then Exit Property
SelRTF = txt.SelRTF
End Property
Property Let SelRTF(sSelRTFA As String)
If TextMode Then Exit Property
txt.SelRTF = sSelRTFA
End Property
Property Get SelStart() As Long
Attribute SelStart.VB_Description = "Returns/sets the starting point of text selected; indicates the position of the insertion point if no text is selected."
Attribute SelStart.VB_MemberFlags = "400"
SelStart = txt.SelStart
End Property
Property Let SelStart(ByVal iSelStartA As Long)
txt.SelStart = iSelStartA
End Property
Property Get SelStrikeThru() As Variant
Attribute SelStrikeThru.VB_Description = "Returns/set the strikethru format of the currently selected text."
Attribute SelStrikeThru.VB_MemberFlags = "400"
If TextMode Then
SelStrikeThru = Null
Else
SelStrikeThru = txt.SelStrikeThru
End If
End Property
Property Let SelStrikeThru(ByVal vSelStrikeThru As Variant)
If TextMode Then Exit Property
txt.SelStrikeThru = vSelStrikeThru
End Property
Property Get SelTabCount() As Variant
Attribute SelTabCount.VB_Description = "Returns/sets the number of tabs. Used in conjunction with the SelTab Property."
Attribute SelTabCount.VB_MemberFlags = "400"
If TextMode Then
SelTabCount = Null
Else
SelTabCount = txt.SelTabCount
End If
End Property
Property Let SelTabCount(ByVal vSelTabCount As Variant)
If TextMode Then Exit Property
txt.SelTabCount = vSelTabCount
End Property
Property Get SelTabs(iElement As Integer) As Variant
Attribute SelTabs.VB_Description = "Returns/sets the absolute tab positions of text. Used in conjunction with the SelTabCount Property."
Attribute SelTabs.VB_MemberFlags = "400"
If TextMode Then
SelTabs = Null
Else
SelTabs = txt.SelTabs(iElement)
End If
End Property
Property Let SelTabs(iElement As Integer, ByVal vSelTabs As Variant)
If TextMode Then Exit Property
txt.SelTabs(iElement) = vSelTabs
End Property
Property Get SelText() As String
Attribute SelText.VB_Description = "Returns/sets the string containing the currently selected text; consists of a zero-length string if no characters are selected."
Attribute SelText.VB_MemberFlags = "400"
SelText = txt.SelText
End Property
Property Let SelText(sSelTextA As String)
txt.SelText = sSelTextA
End Property
Property Get SelUnderline() As Variant
Attribute SelUnderline.VB_Description = "Returns/set the underline format of the currently selected text."
Attribute SelUnderline.VB_MemberFlags = "400"
If TextMode Then
SelUnderline = Null
Else
SelUnderline = txt.SelUnderline
End If
End Property
Property Let SelUnderline(ByVal vSelUnderline As Variant)
If TextMode Then Exit Property
txt.SelUnderline = vSelUnderline
End Property
Property Get Text() As String
Attribute Text.VB_Description = "Returns/sets the text contained in an object."
Attribute Text.VB_UserMemId = 0
If Ambient.UserMode Then
Text = txt.Text
Else
' Show only the first line in property page
Dim iPos As Long
iPos = InStr(txt.Text, sCr)
If iPos Then
Text = Left$(txt.Text, iPos - 1) & "..."
Else
Text = txt.Text
End If
End If
End Property
Property Let Text(sTextA As String)
txt.Text = sTextA
PropertyChanged "Text"
End Property
Property Get TextRTF() As String
Attribute TextRTF.VB_Description = "Returns/sets the text of the control, including all .RTF code."
Public Sub Drag(Optional ByVal ordAction As Integer = vbBeginDrag)
txt.Drag ordAction
End Sub
' Pass through txt method, but it's similar to FindNext
Function Find(sSearch As String, Optional vStart As Variant, _
Optional vEnd As Variant, _
Optional afOptions As Integer = 0) As Long
Attribute Find.VB_Description = "Searches the text for a given string."
With txt
If IsMissing(vStart) Then
If IsMissing(vEnd) Then
' Both missing
If txt.SelLength > 0 Then
vStart = .SelStart
vEnd = .SelStart + .SelLength
Else
' Enhance to start at current position
vStart = .SelStart
vEnd = .SelStart - 1
End If
Else
' Start missing
vStart = .SelStart
End If
Else
If IsMissing(vEnd) Then
' End missing
vEnd = Characters
' else
' None missing
End If
End If
.Find sSearch, vStart, vEnd, afOptions
End With
End Function
' Run-time only (use FileName at design time)
Sub LoadFile(sFileNameA As String, _
Optional ordTextModeA As ELoadSave = elsDefault)
Attribute LoadFile.VB_Description = "Loads an .RTF file or text file."
If sFileNameA = sEmpty Then Exit Sub
BugAssert ordTextModeA >= elsDefault And ordTextModeA <= elstext
If ordTextModeA = elsDefault Then
ordTextModeA = IIf(TextMode, elstext, elsrtf)
End If
If TextMode Then Set Font = fontDefault
' Don't reload clean file
sFileNameA = GetFullPath(sFileNameA)
If sFileNameA = sFilePath And DirtyBit = False Then Exit Sub
' Use RichTextBox method (raise unhandled errors to caller)
txt.LoadFile sFileNameA, ordTextModeA
sFilePath = sFileNameA
DirtyBit = False
End Sub
Sub Move(X As Single, Optional Y As Variant, _
Optional dx As Variant, Optional dy As Variant)
If IsMissing(Y) Then
txt.Move X
ElseIf IsMissing(dx) Then
txt.Move X, Y
ElseIf IsMissing(dy) Then
txt.Move X, Y, dx
Else
txt.Move X, Y, dx, dy
End If
End Sub
Public Sub OLEDrag()
Attribute OLEDrag.VB_Description = "Starts an OLE drag/drop event with the given control as the source."
txt.OLEDrag
End Sub
Public Sub SelPrint(ByVal hDC As Long, Optional fPrintAll As Boolean)
Attribute SelPrint.VB_Description = "Sends formatted text to a device for printing."
With txt
If fPrintAll Then
Dim c As Long
c = .SelLength
.SelLength = 0
.SelPrint hDC
.SelLength = c
Else
.SelPrint hDC
End If
End With
End Sub
Public Sub Refresh()
Attribute Refresh.VB_Description = "Forces a complete repaint."
txt.Refresh
End Sub
Public Sub SetFocus()
txt.SetFocus
End Sub
Sub SaveFile(sFileNameA As String, _
Optional ordTextModeA As ELoadSave = elsDefault)
If sFileNameA = sEmpty Then Exit Sub
BugAssert ordTextModeA >= elsDefault And ordTextModeA <= elstext
If ordTextModeA = elsDefault Then
ordTextModeA = IIf(TextMode, elstext, elsrtf)
End If
' Use RichTextBox method (raise unhandled errors to caller)
sFileNameA = GetFullPath(sFileNameA)
txt.SaveFile sFileNameA, ordTextModeA
sFilePath = sFileNameA
DirtyBit = False
End Sub
Sub ShowWhatsThis()
txt.ShowWhatsThis
End Sub
Public Sub Span(sCharSet As String, _
Optional fForward As Boolean = True, _
Optional fNegate As Boolean = False)
txt.Span sCharSet, fForward, fNegate
End Sub
Public Sub UpTo(sCharSet As String, _
Optional fForward As Boolean = True, _
Optional fNegate As Boolean = False)
Attribute UpTo.VB_Description = "Moves the insertion point up to, but not including, the first character that is a member of the specified character set."
txt.UpTo sCharSet, fForward, fNegate
End Sub
' Events
Sub txt_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
RaiseEvent MouseUp(Button, Shift, X, Y)
End Sub
Sub txt_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
RaiseEvent MouseMove(Button, Shift, X, Y)
End Sub
Sub txt_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
RaiseEvent MouseDown(Button, Shift, X, Y)
End Sub
Sub txt_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyInsert Then
' Insert state changed, so change the variable to match
fOverWrite = Not fOverWrite
StatusEvent
End If
RaiseEvent KeyUp(KeyCode, Shift)
End Sub
Sub txt_KeyPress(KeyAscii As Integer)
RaiseEvent KeyPress(KeyAscii)
End Sub
Sub txt_KeyDown(KeyCode As Integer, Shift As Integer)
RaiseEvent KeyDown(KeyCode, Shift)
End Sub
Sub txt_DblClick()
RaiseEvent DblClick
End Sub
Sub txt_Click()
RaiseEvent Click
End Sub
Sub txt_Change()
RaiseEvent Change
End Sub
Private Sub txt_OLECompleteDrag(Effect As Long)
RaiseEvent OLECompleteDrag(Effect)
End Sub
Private Sub txt_OLEDragDrop(Data As RichTextLib.DataObject, Effect As Long, _